//
//  HDintegralVC.swift
//  HuaDaoPeifu
//
//  Created by ZERO on 2018/6/7.
//  Copyright © 2018年 paiyipai. All rights reserved.
//

import UIKit

class HDintegralVC: UIViewController , UITableViewDelegate, UITableViewDataSource {

    @IBOutlet weak var tableView: UITableView!
    
    fileprivate var integralList:[HDIntegralDetail]?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        title = "积分明细"
        setUI()
        loadIntegralDetail()
    }
    
    func loadIntegralDetail() {
        HDApiManagerHandler.requestUserIntegralList { (list:[HDIntegralDetail]?) in
            guard let list = list else {
                return
            }
            self.integralList = list
            self.tableView.reloadData()
        }
    }

    func setUI() {
        tableView.register(UINib(nibName: "HDWalletDetailCell", bundle: nil), forCellReuseIdentifier: "HDWalletDetailCell")
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return integralList?.count ?? 0
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        let cell = tableView.dequeueReusableCell(withIdentifier: "HDWalletDetailCell", for: indexPath) as! HDWalletDetailCell
        
        cell.unitLabel?.text = "分"
        let model = self.integralList![indexPath.row]
        cell.integralDetailModel = model
        return cell
    }
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        
        let heighttt = 70
        return CGFloat(heighttt)
    }
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}
